<?php
include_once 'admin_check.php'; 
$is_show = array('隐藏','显示');
//get请求 判断是什么页面
$eid = isset($_GET['eid']) && !empty($_GET['eid'])? $_GET['eid']: '';
if($eid){ //如果是编辑页面
  $art = getOne('setting',"set_id = $eid");
}

//post请求
if($_POST){
  $eid = isset($_POST['id']) && !empty($_POST['id'])? $_POST['id']: '';

  //接收数据
  $data['set_name'] = trim($_POST['set_name']);
  $data['set_value'] = trim($_POST['set_value']);
  
  //将数据插入数据库
  //先判断是编辑还是添加
  if($eid){//如果是编辑
    $r = update('setting',$data,"set_id = {$eid}");
    if($r){
      show_msg('更新成功');
    }else{
      show_msg('更新失败');
    }

  }else{ //如果是添加
    
    $r = insert('setting',$data);

    if($r){
      show_msg('插入成功','website_list.php');
    }else{
      show_msg('插入失败');
    }

  }
}
?>
<?php include_once"header.php" ?>
<link rel="stylesheet" type="text/css" href="css/bootstrap-datetimepicker.css">
    <div id="topbar" class="affix">
      <ol class="breadcrumb">
        <li><a href="index.php"><span class="glyphicon glyphicon-home"></span></a></li>
        <li class="active"><?php echo $eid?'编辑':'添加'?>设置</li>
      </ol>
    </div>
    <div class="container">

	 <div class="row">
        <div class="col-md-10 col-lg-11 center-column">
        <form action="" method="post" class="cmxform" enctype="multipart/form-data">
        	<div class="panel">
            <div class="panel-heading">
              <div class="panel-title"><?php echo $eid?'编辑':'添加'?>设置</div>
              <div class="panel-btns pull-right margin-left">
              <a href="set_list.php" class="btn btn-default btn-gradient dropdown-toggle"><span class="glyphicon glyphicon-chevron-left"></span></a>
            	  </div>
            </div>
            <div class="panel-body">
            	  <div class="col-md-7">
                  <div class="form-group">
                    <div class="input-group"> <span class="input-group-addon">设置名称</span>
                      <input type="text" name="set_name" value="<?php echo $art['set_name']?>" class="form-control">
                    </div>
                  </div>

                  <div class="form-group">
                    <div class="input-group"> <span class="input-group-addon">设置值</span>
                      <input type="text" name="set_value" value="<?php echo $art['set_value']?>" class="form-control">
                    </div>
                  </div>

                <div class="col-md-7">
	                <div class="form-group">
                    <input type="hidden" name="id" value="<?php echo $art['set_id']?>">
	                  <input type="submit" value="提交" class="submit btn btn-blue">
	                </div>
                </div>
            </div>
          </div>
          </form>
        </div>
    </div>
  </section>
  <!-- End: Content --> 
</div>

</body>

</html>


